#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 2e5 + 10;
int dp[N];
int arr[N];
int ret;
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)   cin >> arr[i];

    int ret = -101;
    for (int i = 1; i <= n; i++)
    {
        dp[i] = max(dp[i - 1], 0) + arr[i];
        ret = max(ret, dp[i]);

    }
    cout << ret << endl;
    return 0;
}